package 设计模式.责任链模式;

/**
 * 责任人接口
 */
public abstract class Handle {
    protected static final String TO_COMPANY="TO_COMPANY";

    protected static final String TO_AH="TO_AH";

    protected static final String TO_XINGTIAN="TO_XINGTIAN";

    Handle(){}
    Handle(String type){
        this.type=type;
    }
    //处理类型
    private String type;

    private Handle nextHandle;

    public void setNextHandle(Handle handle){
        this.nextHandle=handle;
    }
    protected abstract void handleExamine(LeaveRequest request);

    public final void submit(LeaveRequest request){
        if(request.getType()==null||request.getType()==""){
            throw new RuntimeException("参数异常");
        }
        if(request.getType().equals(this.type)){
            handleExamine(request);
        }else if(nextHandle!=null){
            this.nextHandle.submit(request);
        }else{
            System.out.println("流程结束...");
        }
    }

}
